#include "painThread.h"
#include <time.h>

painThread::painThread()
{	
}

painThread::painThread(Automat *test, Carvis *CarRun)
{	
	this->CarRun = CarRun;
	this->test = test;
	int t = test->loadData("sample_map.xml");
	test->init("Nagel");	
}


painThread::~painThread(void)
{
}

void painThread::run()
{
	int i;
	int CarCount;
	int CarId;
	QPoint currentPosition;
	
	
	while(1)
	{
	CarId=0;
	QHash<QPoint,Car> samochody = test->nextMove();
	QHashIterator<QPoint,Car> j (samochody);
	CarCount = samochody.count();
  	while(j.hasNext())
		{       
			j.next();
 			Car car1 = j.value();
			currentPosition = j.key();
			CarId = car1.getId();
			emit obliczono_ruch(currentPosition, CarId);
			sleep(1);
		}

	}
}